package com.account.book.controller;

import com.account.book.common.response.BaseResult;
import com.account.book.common.response.ResultUtils;
import com.account.book.request.StatisticsReqVo;
import com.account.book.response.StatisticsCollectMoneyRes;
import com.account.book.response.StatisticsMoneyCountRes;
import com.account.book.response.StatisticsMoneyRes;
import com.account.book.service.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author liang-hw
 * @className ReportController
 * @description 图表统计接口
 * @date 2023/11/09 14:20:14
 */
@Api(tags = {"统计接口"})
@RestController
@RequestMapping("/api/statistics")
public class StatisticsController {
    @Autowired
    private StatisticsService statisticsService;

    /**
     * @param @param reportMoneyVo
     * @return @return {@link BaseResult }
     * @author liang-hw
     * @description 收支总览统计
     * @date 2023/11/09 14:21:04
     */
    @ApiOperation(value = "收支总览统计", notes = "收支总览统计")
    @PostMapping("/total")
    public BaseResult total(@Valid @RequestBody StatisticsReqVo statisticsReqVo) {
        StatisticsMoneyCountRes statisticsMoneyCountRes = statisticsService.total(statisticsReqVo);
        return ResultUtils.success(statisticsMoneyCountRes);
    }

    /**
     * @param @param statisticsReqVo
     * @return @return {@link BaseResult }
     * @author liang-hw
     * @description
     * @date 2024/01/11 15:40:30
     */
    @ApiOperation(value = "图表统计", notes = "图表统计")
    @PostMapping("/chartStatistics")
    public BaseResult chartStatistics(@Valid @RequestBody StatisticsReqVo statisticsReqVo) {
        StatisticsMoneyRes statisticsMoneyRes = statisticsService.chartStatistics(statisticsReqVo);
        return ResultUtils.success(statisticsMoneyRes);
    }

    /**
     * @param @param statisticsReqVo
     * @return @return {@link BaseResult }
     * @author liang-hw
     * @description 获取汇总列表
     * @date 2024/01/11 18:39:35
     */
    @ApiOperation(value = "获取汇总列表", notes = "获取汇总列表")
    @PostMapping("/getCollectList")
    public BaseResult getCollectList(@Valid @RequestBody StatisticsReqVo statisticsReqVo) {
        StatisticsCollectMoneyRes statisticsServiceCollectList = statisticsService.getCollectList(statisticsReqVo);
        return ResultUtils.success(statisticsServiceCollectList);
    }
}
